<template>
	<view class="indexs">
		<view :class="'header ' + (banertrue ? 'header_lan' : '')" :style="'padding-top: ' + navH + 'px;'">
			<view class="header_height" :style="'height:' + gaodu + 'px;line-height:' + gaodu + 'px;top:' + gaodutops + 'px;'">
				<view class="index_h_cont3">
					<view class="index_wenben_img" @tap="jumpzuo"><image :src="imgUrl + '/dzx_img22.png'" mode="widthFix"></image></view>
					<view class="index_wenben baise">{{ words.index.title.value }}</view>
				</view>
			</view>
			<view class="coloe_title">s</view>
		</view>
		<view class="index_banner" style="position: relative; background: #fff">
			<image class="index_banner_imgs" :src="imgUrl + '/dzx_img150.png'" mode="widthFix"></image>
			<view class="my_top_cont">
				<view class="my_top">
					<view class="my_top_item1">
						<view class="my_top_item1_l">
							<image :src="userInfo.avatarUrl ? userInfo.avatarUrl : imgUrl + '/dzx_img94.png'" mode="aspectFill"></image>
							<view class="my_top_item1_l_txt">
								<view class="my_top_item1_t1">{{ userInfo['nickName'] }}</view>
								<view class="my_top_item1_t2">ID：{{ userInfo['user_id'] }}</view>
							</view>
						</view>
						<!-- <view class="my_top_item1_r" bindtap="tiaozhuanus" data-url="/pages/mys/my_chongzhi/my_chongzhi">余额充值</view> -->
					</view>

					<view class="my_top_item3">
						<image :src="imgUrl + '/dzx_img95.png'"></image>
						<view class="my_top_item3_btn" @tap="gotiaozhuan" data-url="/pages/mys/my_fenxiaoewm/my_fenxiaoewm">
							<text>{{ $t('page_center.invite_now') }}</text>
							<image :src="imgUrl + '/dzx_img96.png'"></image>
						</view>
					</view>
				</view>
			</view>
		</view>

		<view class="index_center">
			<view class="my_fenxiao_center">
				<view class="my_fenxiao_item1">
					<view class="my_fenxiao_item1_list">
						<view class="my_fenxiao_item1_cont">
							<view class="my_fenxiao_item1_t1">{{ total['today'] }}</view>
							<view class="my_fenxiao_item1_t2">{{ $t('page_center.Income_the_day') }}({{ price_mode.unit }})</view>
						</view>
						<view class="my_fenxiao_item1_cont">
							<view class="my_fenxiao_item1_t1">{{ total['week'] }}</view>
							<view class="my_fenxiao_item1_t2">{{ $t('page_center.Earnings_week') }}({{ price_mode.unit }})</view>
						</view>
						<view class="my_fenxiao_item1_cont">
							<view class="my_fenxiao_item1_t1">{{ total['mouth'] }}</view>
							<view class="my_fenxiao_item1_t2">{{ $t('page_center.Monthly_earnings') }}({{ price_mode.unit }})</view>
						</view>
						<view class="my_fenxiao_item1_cont">
							<view class="my_fenxiao_item1_t1">{{ total['total_money'] }}</view>
							<view class="my_fenxiao_item1_t2">{{ $t('page_center.Cumulative_income') }}</view>
						</view>
						<view class="my_fenxiao_item1_cont">
							<view class="my_fenxiao_item1_t1">{{ total['income'] }}</view>
							<view class="my_fenxiao_item1_t2">{{ $t('page_center.withdrawable') }}</view>
						</view>
						<view class="my_fenxiao_item1_cont">
							<view class="my_fenxiao_item1_t1">{{ total['freeze_income'] }}</view>
							<view class="my_fenxiao_item1_t2">{{ $t('page_center.Withdrawal_audit') }}</view>
						</view>
					</view>
				</view>

				<view class="my_fenxiao_item2">
					<view class="my_fenxiao_item2_list">
						<view class="my_fenxiao_item2_cont" @tap="gotiaozhuan" data-url="/pages/shopadmin/my_balancedetail/my_balancedetail">
							<view class="my_fenxiao_item2_cont_l">
								<image :src="imgUrl + '/dzx_img151.png'"></image>
								<text>{{ words.withdraw_list.title.value }}</text>
							</view>
							<view class="my_fenxiao_item2_cont_r"><image :src="imgUrl + '/dzx_img25.png'"></image></view>
						</view>
						<view class="my_fenxiao_item2_cont" @tap="gotiaozhuan" data-url="/pages/shopadmin/my_tixian/my_tixian">
							<view class="my_fenxiao_item2_cont_l">
								<image :src="imgUrl + '/dzx_img152.png'"></image>
								<text>{{ words.withdraw_apply.title.value }}</text>
							</view>
							<view class="my_fenxiao_item2_cont_r">
								<text>{{ $t('page_center.withdrawable') }}{{ price_mode.unit }}{{ total['income'] }}</text>
								<image :src="imgUrl + '/dzx_img25.png'"></image>
							</view>
						</view>
						<view class="my_fenxiao_item2_cont" @tap="gotiaozhuan" data-url="/pages/shopadmin/my_order/my_order">
							<view class="my_fenxiao_item2_cont_l">
								<image :src="imgUrl + '/dzx_img153.png'"></image>
								<text>{{ words.order.title.value }}</text>
							</view>
							<view class="my_fenxiao_item2_cont_r"><image :src="imgUrl + '/dzx_img25.png'"></image></view>
						</view>
						<view class="my_fenxiao_item2_cont" @tap="gotiaozhuan" data-url="/pages/shopadmin/my_worker/my_worker">
							<view class="my_fenxiao_item2_cont_l">
								<image :src="imgUrl + '/dzx_img154.png'"></image>
								<text>{{ words.team.title.value }}</text>
							</view>
							<view class="my_fenxiao_item2_cont_r"><image :src="imgUrl + '/dzx_img25.png'"></image></view>
						</view>
						<view class="my_fenxiao_item2_cont" @tap="gotiaozhuan" data-url="/pages/shopadmin/my_shop/my_shop">
							<view class="my_fenxiao_item2_cont_l">
								<image :src="imgUrl + '/dzx_img114.png'"></image>
								<text>{{ words.shop.title.value }}</text>
							</view>
							<view class="my_fenxiao_item2_cont_r"><image :src="imgUrl + '/dzx_img25.png'"></image></view>
						</view>
						<view class="my_fenxiao_item2_cont" @tap="gotiaozhuan" data-url="/pages/mys/my_fenxiaoewm/my_fenxiaoewm">
							<view class="my_fenxiao_item2_cont_l">
								<image :src="imgUrl + '/dzx_img155.png'"></image>
								<text>{{ words.qrcode.title.value }}</text>
							</view>
							<view class="my_fenxiao_item2_cont_r"><image :src="imgUrl + '/dzx_img25.png'"></image></view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
// pages/shouye/shouye_zkc/shouye_zkc.js
const app = getApp();

let request = require('../../utils/require');

export default {
	data() {
		return {
			navH: app.globalData.navHeight,
			gaodu: app.globalData.height,
			gaodutops: app.globalData.top,
			imgUrl: app.globalData.imgUrl,
			banertrue: false,
			userInfo: null,
			price_mode: uni.getStorageSync('price_mode'),
			total: [],
			dealer: [],
			words: [],
			is_worker: false
		};
	}, //滑动显示顶部
	onPageScroll: function(e) {
		if (e.scrollTop > this.navH + 50) {
			this.banertrue= true
		} else {
			this.banertrue= false
		}
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad() {
		var that = this;
		this.getDealerData();
		// that.getDealerCenter();
	},
	onShow() {
		var that = this;
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {},
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {},
	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {},
	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {
		return {
			title: uni.getStorageSync('setting').desc,
			path: '/pages/index/index?user=' + this.user,
			imageUrl: '',
			success: function(res) {
				console.log('success22:' + JSON.stringify(res));
			},
			fail: function(err) {
				console.log('fail22:' + JSON.stringify(err));
			}
		};
	},

	methods: {
		gotiaozhuan(e) {
			uni.navigateTo({
				url: e.currentTarget.dataset.url
			});
		},
		getDealerData() {
			var that = this;
			var data = {
				token: uni.getStorageSync('token')
			};
			request.get(`index.php?s=/api/shop.worker/center&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					console.log(res.data.data.is_worker, '222222222');
					this.is_worker = res.data.data.is_worker;
					this.userInfo = res.data.data.user;
					this.dealer = res.data.data.dealer;
					this.words = res.data.data.words;
					if (!this.is_worker) {
						console.log(that.is_worker, 999);
						uni.reLaunch({
							url: '/pages/mys/my_worker/worker_index/worker_index'
						});
					}
				}
			});
			//用于获取财务统计数据
			request.get(`index.php?s=/api/shop.worker/shopdata&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					console.log(res.data.data.total, 'r7876543');
					this.total = res.data.data.total;
				}
			});
		},
		jumpzuo() {
			uni.navigateBack();
		}
	}
};
</script>
<style>
@import './center.css';
</style>
